<!-- 报案信息录入 报案表单  -->
<template>
  
        <el-tabs type="border-card">
            <el-tab-pane label="报案信息">

                <el-card class="box-card" style="margin-top:50px;">
                    <div slot="header" class="card-heaer">
                        <span style="line-height: 36px;">报案信息录入</span>
                        <el-button style="float: right; margin-right:50px;" type="primary" @click="reportall">提交</el-button>
                    </div>

                    <el-card class="box-card">
                        <div slot="header" class="card-heaer">
                            <span style="line-height: 36px;">被保险人信息</span>
                        </div>
                        <el-form :inline="true" :model="peopleinfo" label-width="160px" class="demo-form-inline">
                            <el-form-item label="被保险人姓名:">
                                <el-input v-model="peopleinfo.CUSTNAME" placeholder="被保险人姓名" :disabled="true"></el-input>
                            </el-form-item>
                            <el-form-item label="被保险人联系电话:" class="padleft-150">
                                <el-input v-model="peopleinfo.MOBILE" placeholder="被保险人联系电话" :disabled="true"></el-input>
                            </el-form-item>

                        </el-form>
                        <el-form :inline="true" :model="peopleinfo" label-width="160px" class="demo-form-inline">
                            <el-form-item label="产品类型:">
                                <el-input v-model="peopleinfo.PRODUCTNAME" placeholder="产品类型" :disabled="true"></el-input>
                            </el-form-item>
                             <el-form-item label="保险开始时间" class="padleft-150">
                                    <el-date-picker type="date" placeholder="保险开始时间" v-model="peopleinfo.CERTDATE" :disabled="true"></el-date-picker>
                                </el-form-item>
                        </el-form>
                        <el-form :inline="true" :model="peopleinfo" label-width="160px" class="demo-form-inline">
                           <el-form-item label="保险结束时间" class="padleft-150">
                                    <el-date-picker type="date" placeholder="保险结束时间" v-model="peopleinfo.INSURANCEENDTIME" :disabled="true"></el-date-picker>
                                </el-form-item>
                        </el-form>
                        <el-form :inline="true" :model="peopleinfo" label-width="160px" class="demo-form-inline">

                            <el-form-item label="关键联络人姓名:">
                                <el-input v-model="peopleinfo.Cname" placeholder="关键联络人姓名" :disabled="true"></el-input>
                            </el-form-item>
                            <el-form-item label="关键联络人联系电话:" class="padleft-150">
                                <el-input v-model="peopleinfo.Ctel" placeholder="关键联络人联系电话" :disabled="true"></el-input>
                            </el-form-item>
                        </el-form>
                        <el-form :inline="true" :model="peopleinfo" label-width="160px" class="demo-form-inline">
                            <el-form-item label="与被保险人的关系:">
                                <el-input v-model="peopleinfo.CTOCRELATION" placeholder="与被保险人的关系" :disabled="true"></el-input>
                            </el-form-item>
                        </el-form>
                    </el-card>
                    <div class="space20">
                    </div>
                    <!--报案人信息录入-->
                    <el-card class="box-card">
                        <div slot="header" class="card-heaer">
                            <span style="line-height: 36px;">报案人信息录入</span>
                        </div>

                        <el-form :model="reportuser" :rules.sync="rules" ref="reportuser" label-width="200px">
                            <el-row type="flex" class="row-bg">

                                <el-form-item label="报案人员身份:" prop="REPORTINFORMATION_IDENTITY">
                                    <el-radio-group v-model="reportuser.REPORTINFORMATION_IDENTITY">
                                        <el-radio label="客户报案"></el-radio>
                                        <el-radio label="力众客服报案"></el-radio>
                                    </el-radio-group>
                                </el-form-item>

                            </el-row>
                            <el-row type="flex" class="row-bg" v-show="reportuser.REPORTINFORMATION_IDENTITY=='力众客服报案'">
                                <el-col :span="10">
                                    <el-form-item label="力众代报案原因:" prop="REPORTINFORMATION_IDENTITYWHY" :rules="{
                                                                                                      required: reportuser.REPORTINFORMATION_IDENTITY=='力众客服报案', message: '不能为空', trigger: 'blur'
                                                                                                    }">
                                        <el-input type="textarea" v-model="reportuser.REPORTINFORMATION_IDENTITYWHY" placeholder="力众报案原因" style="width:100%;"></el-input>
                                    </el-form-item>
                                </el-col>

                            </el-row>
                            <el-row type="flex" class="row-bg" v-show="reportuser.REPORTINFORMATION_IDENTITY=='客户报案'">
                                <el-col :span="6">
                                    <el-form-item label="报案人与被保险人的关系:" prop="REPORTINFORMATION_RELATION" :rules="{
                                                                                                      required: reportuser.REPORTINFORMATION_IDENTITY=='客户报案', message: '不能为空', trigger: 'blur'
                                                                                                    }">
                                        <el-select placeholder="报案人与被保险人的关系" v-model="reportuser.REPORTINFORMATION_RELATION">
                                            <el-option label="父子" value="父子"></el-option>
                                            <el-option label="母子" value="母子"></el-option>
                                            <el-option label="夫妻" value="夫妻"></el-option>
                                            <el-option label="本人" value="本人"></el-option>
                                            <el-option label="其他" value="其他"></el-option>
                                        </el-select>
                                    </el-form-item>
                                </el-col>
                                <el-col :span="6" :offset="6">
                                    <el-form-item label="报案方式:" prop="REPORTINFORMATION_WAY" :rules="{
                                                                                                      required: reportuser.REPORTINFORMATION_IDENTITY=='客户报案', message: '不能为空', trigger: 'blur'
                                                                                                    }">
                                        <el-select placeholder="报案方式" v-model="reportuser.REPORTINFORMATION_WAY">
                                            <el-option label="电话" value="电话"></el-option>
                                            <el-option label="微信" value="微信"></el-option>

                                        </el-select>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row type="flex" class="row-bg" v-show="reportuser.REPORTINFORMATION_RELATION!='本人'">
                                <el-col :span="6">
                                    <el-form-item label="报案人姓名:" prop="REPORTINFORMATION_USERNAME" :rules="{
                                                                                                      required: reportuser.REPORTINFORMATION_IDENTITY=='客户报案' && reportuser.REPORTINFORMATION_RELATION!='本人', message: '不能为空', trigger: 'blur'
                                                                                                    }">
                                        <el-input v-model="reportuser.REPORTINFORMATION_USERNAME" placeholder="报案人姓名"></el-input>
                                    </el-form-item>

                                </el-col>
                                <el-col :span="6" :offset="6" v-show="reportuser.REPORTINFORMATION_IDENTITY=='客户报案'">
                                    <el-form-item label="报案人联系电话:" prop="REPORTINFORMATION_TEL" :rules="{
                                                                                                      required: reportuser.REPORTINFORMATION_IDENTITY=='客户报案' && reportuser.REPORTINFORMATION_RELATION!='本人', message: '不能为空', trigger: 'blur'
                                                                                                    }">
                                        <el-input v-model="reportuser.REPORTINFORMATION_TEL" placeholder="报案人联系电话"></el-input>
                                    </el-form-item>
                                </el-col>
                            </el-row>
                            <el-row type="flex" class="row-bg" v-show="reportuser.REPORTINFORMATION_IDENTITY=='客户报案' &&  reportuser.REPORTINFORMATION_RELATION!='本人'">
                                <el-col :span="6">
                                    <el-form-item label="报案人邮箱:" prop="REPORTINFORMATION_EMAIL" :rules="[{
                                                                                                      required: reportuser.REPORTINFORMATION_IDENTITY=='客户报案' &&  reportuser.REPORTINFORMATION_RELATION!='本人', message: '不能为空', trigger: 'blur'
                                                                                                    },
                                                                                                     { type: 'email', message: '请输入正确的邮箱地址', trigger: 'blur,change' }]">
                                        <el-input v-model="reportuser.REPORTINFORMATION_EMAIL" placeholder="报案人邮箱" style="width:100%;"></el-input>
                                    </el-form-item>
                                </el-col>

                            </el-row>
                            <el-row type="flex" class="row-bg">
                                <el-col :span="10">
                                    <el-form-item label="报案事由:" prop="REPORTINFORMATION_CAUSE">
                                        <el-input type="textarea" v-model="reportuser.REPORTINFORMATION_CAUSE" placeholder="报案事由" style="width:100%;"></el-input>
                                    </el-form-item>
                                </el-col>

                            </el-row>
                            <el-form-item label="报案类型:" prop="type">
                                <el-cascader :options="reporttype" :show-all-levels="false" v-model="reportuser.type"></el-cascader>
                                <el-button type="primary" @click="submitForm">添加</el-button>
                                <!--<el-button type="danger" @click="delect">删除</el-button>-->
                            </el-form-item>
                        </el-form>
                    </el-card>
                    <div v-for="(item,index) in fromlist" :key="index">
                        <div class="space20">
                        </div>
                        <keep-alive v-if="item.key=='medical'">
                            <medical :ref="index+1" :checkmedical.sync="checkmedical" :newState="'新增'" :model="index"></medical>
                        </keep-alive>
                        <harmDie :ref="index+1" :newState="'新增'" :checkmedical.sync="checkmedical" :model="index" :modelrules="harmDieRules" :name="item.key" v-if="item.key=='harmDie'"></harmDie>
                        <harmDisability :ref="index+1" :newState="'新增'" :checkmedical.sync="checkmedical" :name="item.key" :model="index" :modelrules="harmDisabilityRules" v-if="item.key=='harmDisability'"></harmDisability>
                        <rescueMeidca :ref="index+1" :newState="'新增'" :checkmedical.sync="checkmedical" :name="item.key" :model="index" :modelrules="rescueMeidcaRules" v-if="item.key=='rescueMeidca'"></rescueMeidca>
                        <rescueMove :ref="index+1" :newState="'新增'" :checkmedical.sync="checkmedical" :name="item.key" :model="index" :modelrules="rescueMoveRules" v-if="item.key=='rescueMove'"></rescueMove>
                        <rescueReturned :ref="index+1" :newState="'新增'" :checkmedical.sync="checkmedical" :name="item.key" :model="index" :modelrules="rescueReturnedRules" v-if="item.key=='rescueReturned'"></rescueReturned>
                        <rescueVisit :ref="index+1" :newState="'新增'" :checkmedical.sync="checkmedical" :name="item.key" :model="index" :modelrules="rescueVisitRules" v-if="item.key=='rescueVisit'"></rescueVisit>
                        <rescueInter :ref="index+1" :newState="'新增'" :checkmedical.sync="checkmedical" :name="item.key" :model="index" :modelrules="rescueInterRules" v-if="item.key=='rescueInter'"></rescueInter>
                        <studyBreak :ref="index+1" :newState="'新增'" :checkmedical.sync="checkmedical" :name="item.key" :model="index" :modelrules="studyBreakRules" v-if="item.key=='studyBreak'"></studyBreak>
                        <travelDelay :ref="index+1" :newState="'新增'" :checkmedical.sync="checkmedical" :name="item.key" :model="index" :modelrules="travelDelayRules   " v-if="item.key=='travelDelay'"></travelDelay>
                        <travelLose :ref="index+1" :newState="'新增'" :checkmedical.sync="checkmedical" :name="item.key" :model="index" :modelrules="travelLoseRules" v-if="item.key=='travelLose'"></travelLose>
                        <three :ref="index+1" :newState="'新增'" :checkmedical.sync="checkmedical" :name="item.key" :model="index" :modelrules="threeRules" v-if="item.key=='three'"></three>
                        <rescueAccompany :ref="index+1" :newState="'新增'" :checkmedical.sync="checkmedical" :name="item.key" :model="index" :modelrules="rescueAccompanyRules" v-if="item.key=='rescueAccompany'"></rescueAccompany>
                    </div>
                </el-card>
            </el-tab-pane>
            <el-tab-pane label="保险利益表">
                <user_liyi>
                </user_liyi>
            </el-tab-pane>
          <el-tab-pane label="保单信息">            
                 <policy-show :type="'保单查看'"  v-if="isGet">
                      </policy-show>
  </el-tab-pane>
        </el-tabs>
   
</template>

<script>
import medical from "@/components/reportForm/medical";
import harmDie from "@/components/reportForm/harmDie";
import harmDisability from "@/components/reportForm/harmDisability";
import rescueMeidca from "@/components/reportForm/rescueMeidca";
import rescueMove from "@/components/reportForm/rescueMove";
import rescueReturned from "@/components/reportForm/rescueReturned";
import rescueVisit from "@/components/reportForm/rescueVisit";
import rescueInter from "@/components/reportForm/rescueInter";
import studyBreak from "@/components/reportForm/studyBreak";
import travelDelay from "@/components/reportForm/travelDelay";
import travelLose from "@/components/reportForm/travelLose";
import three from "@/components/reportForm/three";
import rescueAccompany from "@/components/reportForm/rescueAccompany";
import userLiyi from "@/components/Report/userLiyi";

import PolicyShow from "@/components/Sell/policyShow";
import api from "@/js/api";

import { mapState } from "vuex";
import getid from "@/js/getid";
export default {
  components: {
    "policy-show": PolicyShow,
    medical: medical,
    harmDie: harmDie,
    harmDisability: harmDisability,
    rescueMeidca: rescueMeidca,
    rescueMove: rescueMove,
    rescueReturned: rescueReturned,
    rescueVisit: rescueVisit,
    rescueInter: rescueInter,
    studyBreak: studyBreak,
    travelDelay: travelDelay,
    travelLose: travelLose,
    three: three,
    rescueAccompany: rescueAccompany,
    user_liyi: userLiyi
  },
  data() {
    return {
      peopleinfo: {},
      ismedical: true,
      checkmedical: false,
      reporttype: [],
      isGet: false
    };
  },

  computed: mapState({
    saleDetail: state => state.SealDetail.model,
    // 报案人信息
    reportuser: state => state.reportform.reportuser,
    rules: state => state.reportform.rules,
    reporttype1: state => state.reportform.reporttype1,
    reporttype2: state => state.reportform.reporttype2,
    reporttype3: state => state.reportform.reporttype3,
    //报案类型数组
    fromlist: state => state.reportform.fromlist,
    //医疗保险报案信息
    medical: state => state.reportform.medical,
    //意外死亡
    harmDie: state => state.reportFormItem.harmDie,
    harmDieRules: state => state.reportFormItem.harmDieRules,
    //意外伤残
    harmDisability: state => state.reportFormItem.harmDisability,
    harmDisabilityRules: state => state.reportFormItem.harmDisabilityRules,
    //全球紧急救援-紧急医疗
    rescueMeidca: state => state.reportFormItem.rescueMeidca,
    rescueMeidcaRules: state => state.reportFormItem.rescueMeidcaRules,
    //全球紧急救援-紧急转院
    rescueMove: state => state.reportFormItem.rescueMove,
    rescueMoveRules: state => state.reportFormItem.rescueMoveRules,
    //全球紧急救援-紧急运返
    rescueReturned: state => state.reportFormItem.rescueReturned,
    rescueReturnedRules: state => state.reportFormItem.rescueReturnedRules,
    //陪同
    rescueAccompany: state => state.reportFormItem.rescueAccompany,
    rescueAccompanyRules: state => state.reportFormItem.rescueAccompanyRules,
    //全球紧急救援-探访
    rescueVisit: state => state.reportFormItem.rescueVisit,
    rescueVisitRules: state => state.reportFormItem.rescueVisitRules,
    //全球紧急救援-探访
    rescueInter: state => state.reportFormItem.rescueInter,
    rescueInterRules: state => state.reportFormItem.rescueInterRules,
    //学业中断
    studyBreak: state => state.reportFormItem.studyBreak,
    studyBreakRules: state => state.reportFormItem.studyBreakRules,
    //旅行延误
    travelDelay: state => state.reportFormItem.travelDelay,
    travelDelayRules: state => state.reportFormItem.travelDelayRules,
    //旅行延误
    travelLose: state => state.reportFormItem.travelLose,
    travelLoseRules: state => state.reportFormItem.travelLoseRules,
    //旅行延误
    three: state => state.reportFormItem.three,
    threeRules: state => state.reportFormItem.threeRules
  }),
  methods: {
    //获取 保单信息
    cloneDate(id) {
      let that = this;
      api.SaledetailGetDtoOne(that, { id: id }, function(msg) {
        var cloneObj = msg.Result;       
        if (cloneObj.SALESDETAIL.SALESDETAIL_APPLYTIME)
          cloneObj.SALESDETAIL.SALESDETAIL_APPLYTIME =
            cloneObj.SALESDETAIL.SALESDETAIL_APPLYTIME + "Z";
        if (cloneObj.SALESDETAIL.SALESDETAIL_STARTTIME)
          cloneObj.SALESDETAIL.SALESDETAIL_STARTTIME =
            cloneObj.SALESDETAIL.SALESDETAIL_STARTTIME + "Z";
        if (cloneObj.SALESDETAIL.SALESDETAIL_ENDTIME)
          cloneObj.SALESDETAIL.SALESDETAIL_ENDTIME =
            cloneObj.SALESDETAIL.SALESDETAIL_ENDTIME + "Z";   
    
        that.$store.commit("changer", cloneObj.SALESDETAIL);
       that.saleDetail.CUSTOM = cloneObj.CUSTOM;
        that.saleDetail.RELATIONPEOPLEs = cloneObj.SALESDETAIL.RELATIONPEOPLEs;
        that.saleDetail.QUESTION = cloneObj.SALESDETAIL.QUESTION;

        setTimeout(() => {
            that.isGet = true;
        }, 500);
      
        //先获取数据 在显示
      });
      //传递数据为对象 所以更改后会改变列表数据 1.深拷贝2.关闭时，重新获取数据； 采用了第二种(后期可更换第一种，减少请求)
    },
    submitForm() {
      var obj = {
        key: this.reportuser.type[1],
        obj: {}
      };
     var isDie= sessionStorage.getItem("isDie");
      switch (this.reportuser.type[1]) {
        case "medical":
          this.medical.RI_MEDICAL_ID = getid.getid();
          this.medical.RI_MEDICAL_STATE = "需审核";
          this.medical.RI_MEDICAL_ADDRESS = [];
          obj.obj = JSON.parse(JSON.stringify(this.medical));
          break;
        case "harmDie":
        if(isDie){
            this.$notify.error({
          title: "错误",
          message: "已有意外死亡报案"
        });
          return;
        }
          this.harmDie.RI_DIED_ID = getid.getid();
          this.harmDie.RI_DIED_STATE = "需审核";
          obj.obj = JSON.parse(JSON.stringify(this.harmDie));
          break;
        case "harmDisability":
        if(isDie){
            this.$notify.error({
          title: "错误",
          message: "已有意外死亡报案"
        });
          return;
        }
          this.harmDisability.RI_INJURE_ID = getid.getid();
          this.harmDisability.RI_INJURE_STATE = "需审核";

          obj.obj = JSON.parse(JSON.stringify(this.harmDisability));
          //    obj.obj=this.harmDisability;
          break;
        case "rescueMeidca":
          this.rescueMeidca.RI_HMEDIA_ID = getid.getid();
          this.rescueMeidca.RI_HMEDIA_STATE = "需审核";
          obj.obj = JSON.parse(JSON.stringify(this.rescueMeidca));
          //    obj.obj=this.rescueMeidca;
          break;
        case "rescueMove":
          this.rescueMove.RI_HCHANGE_ID = getid.getid();
          this.rescueMove.RI_HCHANGE_STATE = "需审核";
          obj.obj = JSON.parse(JSON.stringify(this.rescueMove));
          //    obj.obj=this.rescueMove;
          break;
        case "rescueReturned":
          this.rescueReturned.RI_HBACK_ID = getid.getid();
          this.rescueReturned.RI_HBACK_STATE = "需审核";
          obj.obj = JSON.parse(JSON.stringify(this.rescueReturned));
          //    obj.obj=this.rescueReturned;
          break;
        case "rescueVisit":
          this.rescueVisit.RI_HVISIT_ID = getid.getid();
          this.rescueVisit.RI_HVISIT_STATE = "需审核";
          obj.obj = JSON.parse(JSON.stringify(this.rescueVisit));
          //    obj.obj=this.rescueVisit;
          break;
        case "rescueInter":
          this.rescueInter.RI_HBURIAL_ID = getid.getid();
          this.rescueInter.RI_HBURIAL_STATE = "需审核";
          obj.obj = JSON.parse(JSON.stringify(this.rescueInter));
          //    obj.obj=this.rescueInter;
          break;
        case "studyBreak":
          this.studyBreak.RI_ACADEMIC_ID = getid.getid();
          this.studyBreak.RI_ACADEMIC_STATE = "需审核";
          obj.obj = JSON.parse(JSON.stringify(this.studyBreak));
          //    obj.obj=this.studyBreak;
          break;
        case "travelDelay":
          this.travelDelay.RI_TRAVELDELAY_ID = getid.getid();
          this.travelDelay.RI_TRAVELDELAY_STATE = "需审核";
          obj.obj = JSON.parse(JSON.stringify(this.travelDelay));
          //    obj.obj=this.travelDelay;
          break;
        case "travelLose":
          this.travelLose.RI_LOSE_ID = getid.getid();
          this.travelLose.RI_LOSE_STATE = "需审核";
          obj.obj = JSON.parse(JSON.stringify(this.travelLose));
          //    obj.obj=this.travelLose;
          break;
        case "three":
          this.three.RI_OTHER_ID = getid.getid();
          this.three.RI_OTHER_STATE = "需审核";
          obj.obj = JSON.parse(JSON.stringify(this.three));
          //    obj.obj=this.three;
          break;
        case "rescueAccompany":
          this.rescueAccompany.RI_HACCOMPANY_ID = getid.getid();
          this.rescueAccompany.RI_HACCOMPANY_STATE = "需审核";
          obj.obj = JSON.parse(JSON.stringify(this.rescueAccompany));
          //    obj.obj=this.three;
          break;
      }

      this.fromlist.push(obj);
    },
    delect() {
      switch (this.reportuser.type[1]) {
        case "medical":
          this.ismedical = false;
          break;
      }
    },
    reportall() {
      // reportuser
      var f = false;
      this.$refs.reportuser.validate(valid => {
        if (valid) {
          f = true;
        }
      });
      if (!f) {
        this.$notify.error({
          title: "错误",
          message: "请将信息填写完整"
        });
        return;
      }
      let that = this;

      var arr = [];

      for (var i = 0; i < that.fromlist.length; i++) {
        arr[i] = new Promise(function(resolve, reject) {
          that.$refs[i + 1][0].$refs.form.validate(valid2 => {
            if (!valid2) {
              reject();
            } else {
              resolve();
            }
          });
        });
      }

      var p = Promise.all(arr);
      p.then(
        function(value) {
          //报案人信息
          var model = JSON.parse(JSON.stringify(that.reportuser));
          model.REPORTINFORMATION_ID = getid.getid();

          model.SALEDETAILNO = that.peopleinfo.SALEDETAILNO;
          model.REPORTINFORMATION_PRODUCE = that.peopleinfo.PRODUCTNO;
          model.REPORTINFORMATION_STATE = "需审核";
          model.RI_MEDICAL = new Array();
          model.RI_ACADEMIC = new Array();
          model.RI_HBACK = new Array();
          model.RI_HBURIAL = new Array();
          model.RI_HCHANGE = new Array();
          model.RI_HMEDIA = new Array();
          model.RI_HVISIT = new Array();
          model.RI_LOSE = new Array();
          model.RI_OTHER = new Array();
          model.RI_TRAVELDELAY = new Array();
          model.RI_DIED = new Array();
          model.RI_INJURE = new Array();
          model.RI_HACCOMPANY = new Array();
          if (that.fromlist.length == 0) {
            that.$notify.error({
              title: "错误",
              message: "您还没有添加报案类型"
            });
            return;
          }
          for (var i = 0; i < that.fromlist.length; i++) {
            var resultModel = JSON.parse(JSON.stringify(that.fromlist[i].obj));
            switch (that.fromlist[i].key) {
              case "medical":
                if (resultModel.RI_MEDICAL_ADDRESS) {
                  resultModel.RI_MEDICAL_ADDRESS = resultModel.RI_MEDICAL_ADDRESS.join(
                    ","
                  );
                }
                model.RI_MEDICAL.push(resultModel);
                break;
              case "harmDie":
                if (resultModel.RI_DIED_ADDRESS) {
                  resultModel.RI_DIED_ADDRESS = resultModel.RI_DIED_ADDRESS.join(
                    ","
                  );
                }
                model.RI_DIED.push(resultModel);
                break;
              case "harmDisability":
                if (resultModel.RI_INJURE_ADDRESS) {
                  resultModel.RI_INJURE_ADDRESS = resultModel.RI_INJURE_ADDRESS.join(
                    ","
                  );
                }
                model.RI_INJURE.push(resultModel);
                break;
              case "rescueMeidca":
                if (resultModel.RI_HMEDIA_ADDRESS) {
                  resultModel.RI_HMEDIA_ADDRESS = resultModel.RI_HMEDIA_ADDRESS.join(
                    ","
                  );
                }
                model.RI_HMEDIA.push(resultModel);
                break;
              case "rescueMove":
                if (resultModel.RI_HCHANGE_ADDRESS) {
                  resultModel.RI_HCHANGE_ADDRESS = resultModel.RI_HCHANGE_ADDRESS.join(
                    ","
                  );
                }
                model.RI_HCHANGE.push(resultModel);
                break;
              case "rescueReturned":
                if (resultModel.RI_HBACK_ADDRESS) {
                  resultModel.RI_HBACK_ADDRESS = resultModel.RI_HBACK_ADDRESS.join(
                    ","
                  );
                }
                model.RI_HBACK.push(resultModel);
                break;
              case "rescueAccompany":
                if (resultModel.RI_HACCOMPANY_ADDRESS) {
                  resultModel.RI_HACCOMPANY_ADDRESS = resultModel.RI_HACCOMPANY_ADDRESS.join(
                    ","
                  );
                }
                model.RI_HACCOMPANY.push(resultModel);
                break;
              case "rescueVisit":
                if (resultModel.RI_HVISIT_ADDRESS) {
                  resultModel.RI_HVISIT_ADDRESS = resultModel.RI_HVISIT_ADDRESS.join(
                    ","
                  );
                }
                model.RI_HVISIT.push(resultModel);
                break;
              case "rescueInter":
                if (resultModel.RI_HBURIAL_ADDRESS) {
                  resultModel.RI_HBURIAL_ADDRESS = resultModel.RI_HBURIAL_ADDRESS.join(
                    ","
                  );
                }
                model.RI_HBURIAL.push(resultModel);
                break;
              case "studyBreak":
                model.RI_ACADEMIC.push(resultModel);
                break;
              case "travelDelay":
                model.RI_TRAVELDELAY.push(resultModel);
                break;
              case "travelLose":
                model.RI_LOSE.push(resultModel);
                break;
              case "three":
                if (resultModel.RI_OTHER_ADDRESS) {
                  resultModel.RI_OTHER_ADDRESS = resultModel.RI_OTHER_ADDRESS.join(
                    ","
                  );
                }
                model.RI_OTHER.push(resultModel);
                break;
            }
          }
   model.REPORTINFORMATION_ADDPEOPLE=sessionStorage.getItem(
          "userName"
        );
          that.$http.post("ReportInfomation", model).then(
            response => {
              var data = response.body;
              if (data.code == 1) {
                // that.$refs.medicalform.$refs.form.resetFields();
                // this.$refs.reportuser.resetFields();
                that.$notify({
                  title: "提交成功",
                  message: "提交成功，请等待审核！",
                  type: "success"
                });
                that.$router.push({
                  name: "ReportAdd"
                });
              } else {
                that.$notify.error({
                  title: "提交失败",
                  message: data.msg
                });
              }
            },
            response => {
              that.$notify.error({
                title: "网络错误",
                message: "网络错误"
              });
            }
          );
        },
        function(error) {
          that.$notify.error({
            title: "提交失败",
            message: "有没有填写的项"
          });
        }
      );
    }
  },
  created() {
    this.peopleinfo = JSON.parse(sessionStorage.getItem("ReportUser"))[0];
    var saleDetailId = this.peopleinfo.SALEDETAILNO;
    //获取 保险单信息
    this.cloneDate(saleDetailId);
  },
  activated() {
     this.isGet = false;
    this.$store.commit("fromlistEmpty", []);
    this.$store.commit("rescueMoveChanger", {
      RI_HCHANGE_TIME: "",
      RI_HCHANGE_ISUS: ""
    });
    this.$store.commit("rescueMeidcaChanger", {
      RI_HMEDIA_TYPE: "",
      RI_HMEDIA_TIME: "",
      RI_HMEDIA_ISLZ: "",
      RI_HMEDIA_ISUS: ""
    });
    this.$store.commit("rescueAccompanyChanger", {
      RI_HACCOMPANY_ISUS: "",
      RI_HACCOMPANY_TIME: ""
    });
    this.$store.commit("rescueReturnedChanger", {
      RI_HBACK_TIME: "",
      RI_HBACK_ISUS: ""
    });
    this.$store.commit("rescueVisitChanger", {
      RI_HVISIT_TIME: "",
      RI_HVISIT_ISUS: ""
    });
    this.$store.commit("rescueInterChanger", {
      RI_HBURIAL_ISLZ: "",
      RI_HBURIAL_ISUS: "",
      RI_HBURIAL_TIME: ""
    });
    if (this.$route.query["type"].indexOf("畅游") > 0) {
      this.reporttype = this.reporttype1;
    } else if (this.$route.query["type"].indexOf("周详") > 0) {
      this.reporttype = this.reporttype2;
    } else if (this.$route.query["type"].indexOf("安心") > 0) {
      this.reporttype = this.reporttype3;
    } else {
      this.reporttype = [];
      this.$notify.error({
        title: "无此产品产品利益表",
        message: "无此产品产品利益表"
      });
    }
    this.peopleinfo = JSON.parse(sessionStorage.getItem("ReportUser"))[0];
    var saleDetailId = this.peopleinfo.SALEDETAILNO;
    //获取 保险单信息
    this.cloneDate(saleDetailId);
    this.peopleinfo.CERTDATE = new Date(
      this.peopleinfo.CERTDATE + "Z"
    ).toLocaleDateString();
    this.peopleinfo.INSURANCEENDTIME = new Date(
      this.peopleinfo.INSURANCEENDTIME + "Z"
    ).toLocaleDateString();
  }
};
</script>
<style>
.padleft-35 {
  padding-left: 35px;
}

.row-bg input {
  min-width: 190px;
}

.topsubmint {
  position: fixed;
  top: 100px;
  background: #fff;
  z-index: 99;
  padding: 18px 20px;
  box-sizing: border-box;
  font-size: 1.2em;
  font-weight: 300;
  border-bottom: 1px solid rgb(209, 223, 229);
  border-left: 1px solid rgb(209, 223, 229);
  margin-right: 20px;
}
</style>